package com.yuan.yblog.portal.schedules;

import com.yuan.yblog.portal.asyn.AsyncFactory;
import com.yuan.yblog.portal.asyn.AsyncManager;
import com.yuan.yblog.portal.service.WeekRankService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.stereotype.Component;

@Slf4j
@Component
public class Initializer implements ApplicationRunner {

    @Autowired
    WeekRankService weekRankService;

    @Override
    public void run(ApplicationArguments args) {
        // 初始化文章周榜
        weekRankService.initWeekRank();

        // 启动canal监听
        AsyncManager.me().createdThread(AsyncFactory.canalListen());
    }
}
